<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <script th:src="@{/static/scripts/flat-ui.js}"></script>
    <meta charset="UTF-8">
    <link rel="shortcut icon" th:href="@{/static/image/favicon.ico}" type="image/x-icon"/>
    <meta charset="UTF-8">
    <title>茶叶溯源管理系统</title>
    <script th:src="@{/static/js/jquery-3.3.1.min.js}"></script>
    <link th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/static/css/flat-ui.css}" rel="stylesheet">
    <script th:src="@{/static/scripts/flat-ui.min.js}"></script>
    <script th:src="@{/static/scripts/particles.js}"></script>
    <link th:href="@{/static/css/animate.css}" rel="stylesheet">
    <link href="https://www.layuicdn.com/layui/css/layui.css" rel="stylesheet">
</head>

<body>
<div id="particles-js">
    <canvas class="particles-js-canvas-el" width="1322" height="774" style="width: 100%; height: 100%;"></canvas>
</div>
<body>
<div id="particles-js">
    <canvas class="particles-js-canvas-el" width="1322" height="774" style="width: 100%; height: 100%;"></canvas>
</div>

<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black"> 茶叶管理系统</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-smallproduct layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-smallproduct layui-hide-xs"><a href="/product/productList/1">产品管理</a></li>
            <li class="layui-nav-smallproduct layui-hide-xs"><a href="/product/toAddPage">添加产品</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-smallproduct layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <span th:text="${session.adminName}"></span>
                </a>
            </li>
            <li class="layui-nav-smallproduct layui-hide layui-show-md-inline-block">
                <a href="/logout">退出</a>

            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-smallproduct layui-nav-smallproducted">
                <a class="" href="javascript:;">产品管理手册</a>
                <dl class="layui-nav-child">
                    <dd><a href="https://baike.baidu.com/smallproduct/%E7%BA%A2%E8%8C%B6/185424?fr=aladdin">红茶</a></dd>
                    <dd><a href="https://baike.baidu.com/smallproduct/%E4%B9%8C%E9%BE%99%E8%8C%B6/1072?fr=aladdin">乌龙茶</a></dd>
                    <dd><a href="https://baike.baidu.com/smallproduct/%E7%BB%BF%E8%8C%B6/13497">绿茶</a></dd>
                    <dd><a href="https://baike.baidu.com/smallproduct/%E8%8C%89%E8%8E%89%E8%8A%B1%E8%8C%B6/1173">茉莉花茶</a></dd>
                </dl>
                </li>
                <li class="layui-nav-smallproduct">
                    <a href="javascript:;">系统操作手册</a>
                    <dl class="layui-nav-child">
                        <dd><a href="http://www.360doc.com/content/11/1109/12/7082867_163014077.shtml">茶叶管理技术</a></dd>
                        <dd><a href="https://baike.baidu.com/smallproduct/%E8%8C%B6%E5%8F%B6%E5%82%A8%E5%AD%98/1124618?fr=aladdin">茶叶存储</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <fieldset class="layui-elem-field layui-field-title"style="position: relative;top: 100px;left: 250px;">
                        <legend>修改产品</legend>
                    </fieldset>

                        <form class="layui-form layui-form-pane" th:action="${'/product/editProduct/' + product.getPCode}" method="post" name="form"
                              enctype="multipart/form-data" style="position: relative;top: 150px;left: 250px;">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="layui-form-smallproduct">
                                    <label class="layui-form-label">产品编号</label>
                                    <div class="layui-input-block">
                                        <input id="productCode" th:value="${product.getPCode}" type="text" name="productCode"
                                               autocomplete="off" disabled="disabled" class="layui-input">
                                    </div>
                                </div>


                                <div class="layui-form-smallproduct">
                                    <label class="layui-form-label">产品名</label>
                                    <div class="layui-input-block">
                                        <input id="productName" th:value="${product.getPName}" type="text" name="productName"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>


                                <div class="layui-form-smallproduct">
                                    <label class="layui-form-label">生产厂商</label>
                                    <div class="layui-input-block">
                                        <input id="productVendor" th:value="${product.getPmerchant}" type="text" name="productVendor"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>

                                <div class="layui-form-smallproduct">
                                    <label class="layui-form-label">生产地址</label>
                                    <div class="layui-input-block">
                                        <input id="productAddress" th:value="${product.getPAddress}" type="textarea" name="productAddress"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>


                                <div class="layui-form-smallproduct">
                                    <label class="layui-form-label">制茶师</label>
                                    <div class="layui-input-block">
                                        <input id="productMaker" th:value="${product.getPMaker}" type="text" name="productMaker"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                </div>

                                <input type="file" name="file" id="file" accept="image/*" onchange="imgChange(this);"/>
                                <!--文件上传选择按钮-->
                                <div id="preview">
                                    <img id="imghead" th:src="${'http://localhost:8080/img/' + product.getPImg}"/>
                                    <!--图片显示位置-->
                                </div>
                            </div>
                            <div class="col-md-12">

                                <br> <input type="submit"
                                            class="btn btn-primary btn-wide login-btn" value="修改"/>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function(){
        var element = layui.element
            ,layer = layui.layer
            ,util = layui.util
            ,$ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function(othis){
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            ,menuRight: function(){
                layer.open({
                    type: 1
                    ,content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    ,area: ['260px', '100%']
                    ,offset: 'rt' //右上角
                    ,anim: 5
                    ,shadeClose: true
                });
            }
        });
    });
</script>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script type="text/javascript">
    // 选择图片显示
    function imgChange(obj) {
//获取点击的文本框
        let file = document.getElementById("file");
        let imgUrl = window.URL.createObjectURL(file.files[0]);
        let img = document.getElementById('imghead');
        img.setAttribute('src', imgUrl); // 修改img标签src属性值
    };
</script>
</body>
</html>
